import { Tabs } from "nextra/components";
import { Frame } from "@/components";
import SelfHostingCopilotRuntimeCreateEndpoint from "@/snippets/self-hosting-copilot-runtime-create-endpoint.mdx";
import SelfHostingCopilotRuntimeConfigureCopilotKitProvider from "@/snippets/self-hosting-copilot-runtime-configure-copilotkit-provider.mdx";

# Self Hosting (Copilot Runtime)

The Copilot Runtime is the back-end component of CopilotKit, handling the communication with LLM, message history, state and more.

<Frame>
  <div className="w-full pb-4">
  ```mermaid
  sequenceDiagram
    participant core as @copilotkit/react-core
    participant runtime as Copilot Runtime
    participant llm as LLM

    core->>runtime: "Hey, my name is Uli."
    runtime->>llm: Request
    llm->>runtime: Response
    runtime->>core: "Hello Uli, how can I help you?"
  ```
  </div>
</Frame>

You may choose to self-host the Copilot Runtime, or [use Copilot Cloud](https://cloud.copilotkit.ai) (recommended).

## Service Adapters

Service Adapters are responsible for executive the request with the LLM and standardize the request/resopnse format in a way that the Copilot Runtime can understand.

Currently, we support the following service providers/adapters:

- [OpenAIAdapter](/reference/classes/CopilotRuntime/service-adapters/OpenAIAdapter)
- [OpenAIAssistantAdapter](/reference/classes/CopilotRuntime/service-adapters/OpenAIAssistantAdapter)
- [LangChainAdapter](/reference/classes/CopilotRuntime/service-adapters/LangChainAdapter)
- [GroqAdapter](/reference/classes/CopilotRuntime/service-adapters/GroqAdapter)
- [GoogleGenerativeAIAdapter](/reference/classes/CopilotRuntime/service-adapters/GoogleGenerativeAIAdapter)

## Integration

### Step 1: Create an Endpoint

<SelfHostingCopilotRuntimeCreateEndpoint />

### Step 2: Configure the `<CopilotKit>` Provider

<SelfHostingCopilotRuntimeConfigureCopilotKitProvider />

## Further Reading

- [`CopilotRuntime` Class Reference](/reference/classes/copilot-runtime/CopilotRuntime)
- [Service Adapters](/reference/classes/CopilotRuntime/service-adapters/OpenAIAdapter)
